1# 2# Makefile for wav2cdr (mainly Unix / gcc) 3# THIS ONLY WORKS WITH GNU MAKE!!! 4# 5# Platforms / compilers supported: 6# SunOS 4.1.3: no 7# Solaris 2.5, gcc 2.7.2, ld SunOS/ELF (LK-2.0 (S/I) 8# use target solarisgcc (or default) 9# Solaris 2.5, cc SC4.0 18 Oct 1995 C 4.0, ld SunOS/ELF (LK-2.0 (S/I) 10# use target solariscc 11# Linux 2.0.30, gcc 2.7.2.1, GNU ld 12# used by default 13# Linux 2.6.13, gcc 4.0.2, GNU ld 14# used by default 15# MSDOS 6.2, Borland Turbo C 3.1 16# use target msdos 17# (doesn't really work, use Makefile.bc instead) 18# Other targets (Unix): formsdos, tomsdos 19# Other targets (MSDOS): msdosclean 20# Note: make 4.0 seems to crash. Use maker 4.0, or 3.6. 21# Others may work too. 22# 23# Other targets (not supported by stupid makes/systems such as Borland's/M$): 24# depend auto-generate dependencies 25# install install the executable and man page 26# 27# Volker Kuhlmann 28# 29 30 31## where executable and man page is installed 32INSTALLBINDIR = $(HOME)/bin 33INSTALLMANDIR = $(HOME)/man 34MANSECT = 1 35 36 37## where to find chelp.h, vkclib.h 38INCLUDEDIR = ../include 39INCLUDEDIR = . 40#INCLUDEDIR = $(HOME)/include 41 42 43## which getopt to use and where to find it 44# 45# default is now GNUGETOPTC 46ifndef GNUGETOPT 47ifndef MYGETOPT 48 GNUGETOPTC=1 49endif 50endif 51# 52# uncomment this for GNU getopt in the C library: 53ifdef GNUGETOPTC 54 GETOPTFLAGS = -DHAS_GNUGETOPT 55 GETOPTSRCS = 56# 57# uncomment this for GNU getopt, this needs getopt.c, getopt1.c, getopt.h 58# which can be taken from e.g. GNU tar 1.12: 59else 60ifdef GNUGETOPT 61 GETOPTDIR = . 62 GETOPTDIR = gnugetopt 63 GETOPTFLAGS = -DHAS_GNUGETOPT -I$(GETOPTDIR) 64 GETOPTSRCS = $(GETOPTDIR)/getopt.c $(GETOPTDIR)/getopt1.c 65# 66# uncomment this for the quick and dirty getopt which comes with wav2cdr: 67else 68ifdef MYGETOPT 69 GETOPTSRCS = mygetopt.c 70endif 71endif 72endif 73 74 75## CC 76CC = gcc 77CDEFS = 78ifdef DEBUG 79 CDEFS += -DDEBUG 80endif 81#CDEFS += -DDEBUG 82#CDEFS += -DNO_ASSERTMANY 83#CDEFS += -DBIG_ENDIAN 84#CDEFS += -DLITTLE_ENDIAN 85CWARN = -Wall -Wshadow -Wlarger-than-32768 -Wpointer-arith -Wcast-align \ 86 -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations 87CWARN += -Wconversion -Wstrict-prototypes 88CWARN += -W 89CFL = -ansi -pedantic 90ifndef NOOPT 91 CFL += -O2 92endif 93CFL += -g 94CFLAGS = $(CFL) -I$(INCLUDEDIR) $(CDEFS) $(GETOPTFLAGS) $(CWARN) 95# 96# Solaris gcc: 97CDEFSsolgcc = 98#CDEFSsolgcc += -DDEBUG 99#CDEFSsolgcc += -DNO_ASSERTMANY 100#CDEFSsolgcc += -DBIG_ENDIAN 101# 102# Solaris cc: 103# -misalign and not HANDLE_MISALIGNED will hang chartnet lib (incorrect values 104# by ...swap_endian...() ?) 105# HANDLE_MISALIGN will work with and without -misalign 106# Neither of the 2 will turn into bus errors 107CCsolcc = cc 108CDEFSsolcc = 109#CDEFSsolcc += -DDEBUG 110#CDEFSsolcc += -DNO_ASSERTMANY 111#CDEFSsolcc += -DBIG_ENDIAN 112CFLAGSsolcc = -Xc -I$(INCLUDEDIR) 113#CFLAGSsolcc += -misalign 114CFLAGSsolcc += -xO4 115#CFLAGSsolcc += -g 116 117## LD 118# 119# $(CC): 120LD = $(CC) 121LDFLAGS = $(CFL) -I$(INCLUDEDIR) $(GETOPTFLAGS) 122# 123# Solaris cc/ld: 124LDsolcc = cc 125LDFLAGSsolcc = -I$(INCLUDEDIR) $(GETOPTFLAGS) 126 127## AWK, SED 128AWK = awk 129SED = sed 130 131## Strip backspace + following char 132CX = cx -q bs 133 134 135 136HSRCS1 = $(INCLUDEDIR)/chelp.h mygetopt.h 137HSRCS2 = wav2cdr.h 138HSRCS = $(HSRCS1) $(HSRCS2) 139 140CSRCS = wav2cdr.c cmdarg.c data.c fileio.c process.c 141 142MADESRCS = version.-c usage.-c help.-c 143 144OBJS = $(CSRCS:.c=.o) $(GETOPTSRCS:.c=.o) 145 146 147 148 149# Implicit Rules 150 151.1.txt: 152 #nroff -man $< | $(CX) >$*.txt 153 if [ `uname -s` = "Linux" ]; then\ 154 (echo -e ".ll 7.3i\n.pl 1100i"; cat $<; echo ".pl \n(nlu+10" )\ 155 | gtbl | groff -Tascii -mandoc | $(CX) >$*.txt;\ 156 else\ 157 nroff -man $< | $(CX) >$*.txt;\ 158 fi 159.txt.-c: 160 $(SED) < $< 's/"/\\x22""/g' | $(AWK) > $*.-c '{print "\""$$0"\\n\""}' 161 chmod a+r $*.-c 162.c.o: 163# $(CC) -c $(CFLAGS) $(XCFLAGS) $< 164 $(CC) -c $(CFLAGS) $(XCFLAGS) -o $*.o $< 165.SUFFIXES: 166.SUFFIXES: .1 .txt .-c .c .o 167 168 169# Explicit Rules and Individual File Dependencies 170 171all: wav2cdr 172.PHONY: all build made delmadesources man depend showvar install uninstall 173 174build: veryclean all 175 176wav2cdr: $(OBJS) 177 $(LD) -o wav2cdr $(LDFLAGS) $(XLDFLAGS) \ 178 $(OBJS) 179 180#$(GETOPTSRCS): 181# $(CC) -c $(CFLAGS) $(GETOPTFLAGS) -o $*.o $(XCFLAGS) $< 182 183# this is unlikely to work for Mickey$oft - don't delete version/usage/help.-c! 184made: delmadesources $(MADESRCS) 185delmadesources: 186 rm -f $(MADESRCS) 187wav2cdr.o: $(MADESRCS) 188 189# text version of the man page (no ^H) 190man: 191 rm -f wav2cdr.txt 192 $(MAKE) $(MAKEFLAGS) wav2cdr.txt 193 chmod 644 wav2cdr.txt 194 195# help file compiled into the binary: 196# (this is just for the developer's convenience, and might not work reliably!) 197help.txt: wav2cdr.txt 198 sed <wav2cdr.txt \ 199 -e 's:44100 Hz:%li Hz:'\ 200 -e 's:size of 2352:size of %i:'\ 201 -e 's:size of 2352:size of %i:'\ 202 -e 's:are 75 sec:are %i sec:' \ 203 | awk '!/^$$/ {print; el=0; next}; /^$$/ {if (!el) print; el=1}' \ 204 >help.txt 205 chmod 644 help.txt 206 #test `grep % help.txt | wc -l` = 3 207 test `tr ' ' '\n' < help.txt | grep % | wc -l` = 3 208 209# a) This will screw up BorCrap make (targets may only appear once). 210# b) The makedepend on our Solaris X11R5 has no -Y. (X11R6 has) 211depend: $(MADESRCS) 212 makedepend -f Makefile.gmake -- $(CFLAGS) $(XCCFLAGS) -- $(CSRCS) 213 214showvar: 215 @echo "CC =" $(CC) 216 @echo "CFLAGS =" $(CFLAGS) 217 @echo "CCFLAGS =" $(CCFLAGS) 218 @echo "XCFLAGS =" $(XCFLAGS) 219 @echo "XCCFLAGS =" $(XCCFLAGS) 220 @echo "LD =" $(LD) 221 @echo "LDFLAGS =" $(LDFLAGS) 222 @echo "XLDFLAGS =" $(XLDFLAGS) 223 @echo "AR =" $(AR) 224 @echo "ARFLAGS =" $(ARFLAGS) 225 226install: all uninstall 227 if [ ! -d $(INSTALLBINDIR) ]; then mkdir -p $(INSTALLBINDIR); fi 228 cp -p wav2cdr $(INSTALLBINDIR) 229 cd $(INSTALLBINDIR); chmod 755 wav2cdr 230 if [ ! -d $(INSTALLMANDIR)/man$(MANSECT) ]; then \ 231 mkdir -p $(INSTALLMANDIR)/man$(MANSECT); fi 232 cp -p wav2cdr.1 $(INSTALLMANDIR)/man$(MANSECT) 233 cd $(INSTALLMANDIR)/man$(MANSECT); chmod 644 wav2cdr.1 234 235uninstall: 236 -cd $(INSTALLBINDIR); rm -f wav2cdr 237 238.PHONY: clean veryclean vclean veryveryclean vvclean 239clean: 240 rm -f *.o *% Makefile*.bak core 241 -if [ "$(GETOPTDIR)" != "" ]; then rm $(GETOPTDIR)/*.o; fi; exit 0 242 243veryclean vclean: clean 244 rm -f wav2cdr 245 -rm $(INCLUDEDIR)/*.[ch]%; exit 0 246 247veryveryclean vvclean: veryclean 248 makedepend -f Makefile.gmake -- -- 249 rm -f Makefile.gmake.bak $(MADESRCS) 250 rm -f *.obj *.exe wav2cdr.sym wav2cdr.map 251 rm -f tc0000.swp turboc.\$$ln bcc.tmp 252 253 254# Support different platforms with one Makefile 255# default is Linux gcc / GNU ld 256# Target "solaris" switches variables to solaris, but this supports only 257# one target! (target all in this case) 258# Note this requires SUN make, not GNU make! 259 260.PHONY: solarisgcc solariscc linux warnsunmake 261 262# Solaris gcc 263solarisgcc := DEFS = $(CDEFSsolgcc) 264solarisgcc: warnsunmake all 265 266# Solaris cc 267solariscc := CC = $(CCsolcc) 268solariscc := DEFS = $(CDEFSsolcc) 269solariscc := CFLAGS = $(CFLAGSsolcc) 270solariscc := LD = $(LDsolcc) 271solariscc := LDFLAGS = $(LDFLAGSsolcc) 272solariscc: warnsunmake all 273 274linux: all 275 276warnsunmake: 277 @echo "Be sure to use SUN make or it won't work!" 278 @echo "-----------------------------------------" 279 280 281# these 2 targets for administration only 282.PHONY: pack sedver 283# pack it up 284pack: 285 @echo "================================================" 286 @echo "Making wav2cdr for version [$$""(VERSION)$$""(WV)]: $(VERSION)$(WV)" 287 @echo "================================================" 288# $(MAKE) $(MAKEFLAGS) $(MADESRCS) wav2cdr.txt 289 $(MAKE) $(MADESRCS) wav2cdr.txt 290 chmod go+r $(MADESRCS) wav2cdr.txt 291 cd ..; tar -cvhf wav2cdr-$(VERSION)$(WV).tar --owner root --group root \ 292 wav2cdr/README wav2cdr/BUGS wav2cdr/TODO wav2cdr/COPYING \ 293 wav2cdr/ChangeLog \ 294 wav2cdr/Make* \ 295 wav2cdr/*.[ch1] \ 296 wav2cdr/help* wav2cdr/usage* wav2cdr/version* \ 297 wav2cdr/wav2cdr.txt \ 298 wav2cdr/wav2cdr.lsm wav2cdr/wav2cdr*.spec 299 -rm ../wav2cdr-$(VERSION)$(WV).tar.bz2 300 bzip2 -9 ../wav2cdr-$(VERSION)$(WV).tar 301VO=wav2cdr .* Copyright (C) 19.* Volker Kuhlmann 302VN=wav2cdr $(VERSION)$(WV) Copyright (C) 1997, 1998, 1999, 2000, 2006 Volker Kuhlmann 303sedver: 304 for n in $(HSRCS2) $(CSRCS); do \ 305 sed <$$n >$$n.sed -e 's/$(VO)/$(VN)/'; \ 306 if diff $$n $$n.sed >/dev/null; \ 307 then rm $$n.sed; \ 308 else cat $$n.sed >$$n; rm $$n.sed; \ 309 fi; \ 310 done 311 312 313# MSDOS 314# Borland C 3.1 make (Borland make 3.6 + 4.0) has no useful make utility, 315# therefore must use a different approach: 316# NOT YET TESTED! 317 318CCmsdos = bcc 319CFLAGSmsdos = \ 320 -I..\include \ 321 -3 -A -k -mc -N -P-.C -r -y -Y- \ 322 $(XCCFLAGS) 323#CFLAGSmsdos = \ 324# -I..\include \ 325# -3 -a -A -ff- -Ff=32767 -G -k -mc -N -P-.C -p- -r -u -vi- -y -Y- \ 326# $(XCCFLAGS) 327LDmsdos = $(CCmsdos) $(CFLAGSmsdos) 328#LDmsdos = bcc 329#LDFLAGSmsdos = -a -ff- -k -mc -N -u -Y- -y 330 331.c.obj: 332 $(CCmsdos) $(CFLAGSmsdos) -c {$< } 333.SUFFIXES: .obj 334 335.PHONY: msdos tomsdos msdosclean 336 337msdos: wav2cdr.exe 338 339wav2cdr.exe: $(OBJS:.o=.obj) 340 $(LDmsdos) $(LDFLAGSmsdos) $(OBJS:.o=.obj) 341# tlink @turboc.lnk 342 343tomsdos: 344 if [ ! -d /D/prog/vkclib ]; then mkdir -p /D/prog/vkclib; fi 345 cp -p Makefile vkclib.[ch] /D/prog/vkclib 346 cp -p mf /D/prog/vkclib/makefile 347 rm -f mf 348 349msdosclean: 350 del *.obj 351 del wav2cdr.sym 352 del wav2cdr.map 353 del tc0000.swp 354 del turboc.$$ln 355 del turboc.$ln 356 357# For BorCrap make <4.0 delete all these dependency lines after the last 358# comment (and a lot of other things...). 359 360# DO NOT DELETE - AUTOMATICALLY CREATED BY MAKEDEPEND!!! 361# DO NOT DELETE THIS LINE -- make depend depends on it. 362