1#
2# OpenWatcom compile and link utility
3#
4VPATH = $(SRC)
5include $(MAKEDIR)/syslinux.mk
6
7WCL	= wcl
8WCLOPT	= -6 -osx -mt -bt=DOS -l=COM
9
10WCL_IS_GOOD := $(shell $(WCL) $(WCLOPT) \
11        -o hello.exe $(SRC)/../win/hello.c >/dev/null 2>&1 ; echo $$?)
12
13UPX     = upx
14
15NASM    = nasm
16NASMOPT = -Ox
17
18WCTARGETS = mdiskchk.com
19NSTARGETS = eltorito.sys copybs.com
20WCOBJS    = $(addprefix $(SRC)/,$(WCTARGETS))
21NSOBJS    = $(addprefix $(OBJ)/,$(NSTARGETS))
22TARGETS   = $(WCTARGETS) $(NSTARGETS)
23
24%.obj: %.c
25	$(WCL) $(WCLOPT) -c -fo=$@ $<
26
27%.com: %.obj
28	$(WCL) $(WCLOPT) -fe=$@ $<
29	$(UPX) --ultra-brute --lzma $@ || \
30		$(UPX) --ultra-brute $@ || \
31		true
32	rm -f $*.0*
33	chmod a-x $@
34
35%.sys: %.asm
36	$(NASM) $(NASMOPT) -f bin -o $@ -l $*.lst $<
37	$(UPX) --ultra-brute --lzma $@ || \
38		$(UPX) --ultra-brute $@ || \
39		true
40	rm -f $*.0*
41	chmod a-x $@
42
43%.com: %.asm
44	$(NASM) $(NASMOPT) -f bin -o $@ -l $*.lst $<
45	$(UPX) --ultra-brute --lzma $@ || \
46		$(UPX) --ultra-brute $@ || \
47		true
48	rm -f $*.0*
49	chmod a-x $@
50
51ifeq ($(WCL_IS_GOOD),0)
52all: $(TARGETS)
53else
54all: $(NSTARGETS)
55	rm -f $(WCTARGETS)
56endif
57
58tidy dist:
59	-rm -f *.obj *.lst *.o *.0*
60
61clean: tidy
62
63spotless: clean
64	-rm -f $(NSTARGETS) *~
65
66installer: all
67
68install: installer
69	mkdir -m 755 -p $(INSTALLROOT)$(AUXDIR)/dosutil
70	install -m 644 $(WCOBJS) $(INSTALLROOT)$(AUXDIR)/dosutil
71	install -m 644 $(NSOBJS) $(INSTALLROOT)$(AUXDIR)/dosutil
72