xref: /freebsd/contrib/bmake/mk/posix.mk (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1# SPDX-License-Identifier: BSD-2-Clause
2#
3# $Id: posix.mk,v 1.3 2024/02/17 17:26:57 sjg Exp $
4#
5#	@(#) Copyright (c) 2022, Simon J. Gerraty
6#
7#	This file is provided in the hope that it will
8#	be of use.  There is absolutely NO WARRANTY.
9#	Permission to copy, redistribute or otherwise
10#	use this file is hereby granted provided that
11#	the above copyright notice and this notice are
12#	left intact.
13#
14#	Please send copies of changes and bug-fixes to:
15#	sjg@crufty.net
16#
17
18# The minimal set of rules required by POSIX
19
20.if !defined(%POSIX)
21.error ${.newline}Do not inlcude this directly, put .POSIX: at start of Makefile
22.endif
23
24.if ${.MAKEFLAGS:M-r} == ""
25# undo some work done by sys.mk
26.SUFFIXES:
27.undef ARFLAGS
28.undef CC CFLAGS
29.undef FC FFLAGS
30.undef LDFLAGS LFLAGS
31.undef RANLIBFLAGS
32.undef YFLAGS
33.endif
34
35.SUFFIXES: .o .c .y .l .a .sh .f
36
37# these can still be set via environment
38AR ?= ar
39ARFLAGS ?= -rv
40CC ?= c99
41CFLAGS ?= -O
42FC ?= fort77
43FFLAGS ?= -O 1
44LDFLAGS ?=
45LEX ?= lex
46LFLAGS ?=
47RANLIBFLAGS ?= -D
48YACC ?= yacc
49YFLAGS ?=
50
51.c:
52	${CC} ${CFLAGS} ${LDFLAGS} -o $@ $<
53
54
55.f:
56	${FC} ${FFLAGS} ${LDFLAGS} -o $@ $<
57
58
59.sh:
60	cp $< $@
61	chmod a+x $@
62
63
64.c.o:
65	${CC} ${CFLAGS} -c $<
66
67
68.f.o:
69	${FC} ${FFLAGS} -c $<
70
71
72.y.o:
73	${YACC} ${YFLAGS} $<
74	${CC} ${CFLAGS} -c y.tab.c
75	rm -f y.tab.c
76	mv y.tab.o $@
77
78
79.l.o:
80	${LEX} ${LFLAGS} $<
81	${CC} ${CFLAGS} -c lex.yy.c
82	rm -f lex.yy.c
83	mv lex.yy.o $@
84
85
86.y.c:
87	${YACC} ${YFLAGS} $<
88	mv y.tab.c $@
89
90
91.l.c:
92	${LEX} ${LFLAGS} $<
93	mv lex.yy.c $@
94
95
96.c.a:
97	${CC} -c ${CFLAGS} $<
98	${AR} ${ARFLAGS} $@ $*.o
99	rm -f $*.o
100
101
102.f.a:
103	${FC} -c ${FFLAGS} $<
104	${AR} ${ARFLAGS} $@ $*.o
105	rm -f $*.o
106
107