1# Makefile for PDCurses library for SDL
2
3O = o
4
5ifndef PDCURSES_SRCDIR
6	PDCURSES_SRCDIR	= ..
7endif
8
9include $(PDCURSES_SRCDIR)/libobjs.mif
10
11osdir		= $(PDCURSES_SRCDIR)/sdl1
12
13PDCURSES_SDL_H	= $(osdir)/pdcsdl.h
14
15ifeq ($(DEBUG),Y)
16        CFLAGS  = -g -Wall -DPDCDEBUG
17else
18        CFLAGS  = -O2 -Wall
19endif
20
21CC		= gcc
22BUILD		= $(CC) $(CFLAGS) -I$(PDCURSES_SRCDIR)
23LDFLAGS		= -mwindows $(LIBCURSES)
24
25BASEDEF		= $(PDCURSES_SRCDIR)\exp-base.def
26
27DEFDEPS		= $(BASEDEF)
28
29DEFFILE		= pdcurses.def
30
31ifeq ($(DLL),Y)
32	BUILD += -DPDC_DLL_BUILD
33	LIBEXE = gcc $(DEFFILE)
34	LIBFLAGS = -Wl,--out-implib,libpdcurses.a -shared -o
35	LIBCURSES = pdcurses.dll
36	CLEAN = $(LIBCURSES) *.a $(DEFFILE)
37	POST = -lSDL
38else
39	LIBEXE = ar
40	LIBFLAGS = rcv
41	LIBCURSES = libpdcurses.a
42	CLEAN = *.a
43	LDFLAGS += -lSDL
44endif
45
46DEMOS += sdltest.exe
47
48.PHONY: all libs clean demos
49
50all:	libs demos
51
52libs:	$(LIBCURSES)
53
54clean:
55	-del *.o $(CLEAN) *.exe
56
57demos:	$(DEMOS)
58	strip *.exe
59
60pdcurses.dll: $(DEFFILE)
61
62$(DEFFILE): $(DEFDEPS)
63	echo LIBRARY pdcurses > $@
64	echo EXPORTS >> $@
65	type $(BASEDEF) >> $@
66	echo pdc_screen >> $@
67	echo pdc_font >> $@
68	echo pdc_icon >> $@
69	echo pdc_back >> $@
70	echo pdc_sheight >> $@
71	echo pdc_swidth >> $@
72	echo pdc_yoffset >> $@
73	echo pdc_xoffset >> $@
74
75$(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
76	$(LIBEXE) $(LIBFLAGS) $@ $? $(POST)
77
78$(LIBOBJS) $(PDCOBJS) : $(PDCURSES_HEADERS)
79$(PDCOBJS) : $(PDCURSES_SDL_H)
80$(DEMOS) : $(PDCURSES_CURSES_H) $(LIBCURSES)
81tui.o tuidemo.o : $(PDCURSES_CURSES_H)
82terminfo.o: $(TERM_HEADER)
83panel.o ptest.exe: $(PANEL_HEADER)
84
85$(LIBOBJS) : %.o: $(srcdir)/%.c
86	$(BUILD) -c $<
87
88$(PDCOBJS) : %.o: $(osdir)/%.c
89	$(BUILD) -c $<
90
91firework.exe newdemo.exe rain.exe testcurs.exe worm.exe xmas.exe \
92ptest.exe: %.exe: $(demodir)/%.c
93	$(BUILD) -o $@ $< $(LDFLAGS)
94
95tuidemo.exe: tuidemo.o tui.o
96	$(CC) -o $@ tuidemo.o tui.o $(LDFLAGS)
97
98tui.o: $(demodir)/tui.c $(demodir)/tui.h
99	$(BUILD) -c $<
100
101tuidemo.o: $(demodir)/tuidemo.c $(demodir)/tui.h
102	$(BUILD) -c $<
103
104sdltest.exe: $(osdir)/sdltest.c
105	$(BUILD) -o $@ $< -mwindows $(LIBCURSES) -lmingw32 -lSDLmain -lSDL
106