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