patch-Makefile 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. $OpenBSD: patch-Makefile,v 1.7 2016/03/10 23:05:53 naddy Exp $
  2. --- Makefile.orig Wed Apr 26 21:14:26 2006
  3. +++ Makefile Thu Mar 10 23:54:20 2016
  4. @@ -44,7 +44,7 @@ WAV49 = -DWAV49
  5. # CCFLAGS = -c -O
  6. CC = gcc -ansi -pedantic
  7. -CCFLAGS = -c -O2 -DNeedFunctionPrototypes=1
  8. +CCFLAGS = -c -DNeedFunctionPrototypes=1
  9. LD = $(CC)
  10. @@ -80,7 +80,7 @@ INSTALL_ROOT =
  11. GSM_INSTALL_ROOT = $(INSTALL_ROOT)
  12. GSM_INSTALL_LIB = $(GSM_INSTALL_ROOT)/lib
  13. -GSM_INSTALL_INC = $(GSM_INSTALL_ROOT)/inc
  14. +GSM_INSTALL_INC = $(GSM_INSTALL_ROOT)/include
  15. GSM_INSTALL_MAN = $(GSM_INSTALL_ROOT)/man/man3
  16. @@ -106,7 +106,10 @@ COMPRESS = compress
  17. COMPRESSFLAGS =
  18. # RANLIB = true
  19. RANLIB = ranlib
  20. +RM = rm -f
  21. +PICFLAG = -fpic
  22. +
  23. #
  24. # You shouldn't have to configure below this line if you're porting.
  25. #
  26. @@ -136,11 +139,16 @@ CFLAGS = $(CCFLAGS) $(SASR) $(DEBUG) $(MULHACK) $(FAST
  27. LFLAGS = $(LDFLAGS) $(LDINC)
  28. ######### It's $(LD) $(LFLAGS)
  29. +.SUFFIXES: .o .so
  30. # Targets
  31. LIBGSM = $(LIB)/libgsm.a
  32. +LIBgsm_VERSION= 1.0
  33. +LIBGSMSO = $(LIB)/libgsm.so.${LIBgsm_VERSION}
  34. +INSTALLED_LIBGSMSO = $(GSM_INSTALL_LIB)/libgsm.so.${LIBgsm_VERSION}
  35. +
  36. TOAST = $(BIN)/toast
  37. UNTOAST = $(BIN)/untoast
  38. TCAT = $(BIN)/tcat
  39. @@ -258,6 +266,7 @@ STUFF = ChangeLog \
  40. GSM_INSTALL_TARGETS = \
  41. $(GSM_INSTALL_LIB)/libgsm.a \
  42. + $(INSTALLED_LIBGSMSO) \
  43. $(GSM_INSTALL_INC)/gsm.h \
  44. $(GSM_INSTALL_MAN)/gsm.3 \
  45. $(GSM_INSTALL_MAN)/gsm_explode.3 \
  46. @@ -277,9 +286,12 @@ TOAST_INSTALL_TARGETS = \
  47. $(CC) $(CFLAGS) $?
  48. @-mv `$(BASENAME) $@` $@ > /dev/null 2>&1
  49. +.c.so:
  50. + $(CC) $(CFLAGS) $(PICFLAG) -DPIC $? -o $@
  51. +
  52. # Target rules
  53. -all: $(LIBGSM) $(TOAST) $(TCAT) $(UNTOAST)
  54. +all: $(LIBGSM) $(LIBGSMSO) $(TOAST) $(TCAT) $(UNTOAST)
  55. @-echo $(ROOT): Done.
  56. tst: $(TST)/lin2cod $(TST)/cod2lin $(TOAST) $(TST)/test-result
  57. @@ -299,8 +311,11 @@ install: toastinstall gsminstall
  58. # The basic API: libgsm
  59. +$(LIBGSMSO): $(LIB) $(GSM_OBJECTS:.o=.so)
  60. + $(CC) -shared $(PICFLAG) -o $@ $(GSM_OBJECTS:.o=.so)
  61. +
  62. $(LIBGSM): $(LIB) $(GSM_OBJECTS)
  63. - -rm $(RMFLAGS) $(LIBGSM)
  64. + $(RM) $(RMFLAGS) $(LIBGSM)
  65. $(AR) $(ARFLAGS) $(LIBGSM) $(GSM_OBJECTS)
  66. $(RANLIB) $(LIBGSM)
  67. @@ -308,14 +323,14 @@ $(LIBGSM): $(LIB) $(GSM_OBJECTS)
  68. # Toast, Untoast and Tcat -- the compress-like frontends to gsm.
  69. $(TOAST): $(BIN) $(TOAST_OBJECTS) $(LIBGSM)
  70. - $(LD) $(LFLAGS) -o $(TOAST) $(TOAST_OBJECTS) $(LIBGSM) $(LDLIB)
  71. + $(CC) $(LFLAGS) -o $(TOAST) $(TOAST_OBJECTS) -lgsm $(LDLIB)
  72. $(UNTOAST): $(BIN) $(TOAST)
  73. - -rm $(RMFLAGS) $(UNTOAST)
  74. + $(RM) $(RMFLAGS) $(UNTOAST)
  75. $(LN) $(TOAST) $(UNTOAST)
  76. $(TCAT): $(BIN) $(TOAST)
  77. - -rm $(RMFLAGS) $(TCAT)
  78. + $(RM) $(RMFLAGS) $(TCAT)
  79. $(LN) $(TOAST) $(TCAT)
  80. @@ -342,63 +357,51 @@ toastinstall:
  81. gsmuninstall:
  82. -if [ x"$(GSM_INSTALL_ROOT)" != x ] ; then \
  83. - rm $(RMFLAGS) $(GSM_INSTALL_TARGETS) ; \
  84. + $(RM) $(RMFLAGS) $(GSM_INSTALL_TARGETS) ; \
  85. fi
  86. toastuninstall:
  87. -if [ x"$(TOAST_INSTALL_ROOT)" != x ] ; then \
  88. - rm $(RMFLAGS) $(TOAST_INSTALL_TARGETS); \
  89. + $(RM) $(RMFLAGS) $(TOAST_INSTALL_TARGETS); \
  90. fi
  91. $(TOAST_INSTALL_BIN)/toast: $(TOAST)
  92. - -rm $@
  93. - cp $(TOAST) $@
  94. - chmod 755 $@
  95. + ${BSD_INSTALL_PROGRAM} $(TOAST) $@
  96. $(TOAST_INSTALL_BIN)/untoast: $(TOAST_INSTALL_BIN)/toast
  97. - -rm $@
  98. - ln $? $@
  99. + cd $(TOAST_INSTALL_BIN) && ln -sf toast untoast
  100. $(TOAST_INSTALL_BIN)/tcat: $(TOAST_INSTALL_BIN)/toast
  101. - -rm $@
  102. - ln $? $@
  103. + cd $(TOAST_INSTALL_BIN) && ln -sf toast tcat
  104. $(TOAST_INSTALL_MAN)/toast.1: $(MAN)/toast.1
  105. - -rm $@
  106. - cp $? $@
  107. - chmod 444 $@
  108. + ${BSD_INSTALL_MAN} $? $@
  109. + cd $(TOAST_INSTALL_MAN) && ln -sf toast.1 untoast.1 && \
  110. + ln -sf toast.1 tcat.1
  111. $(GSM_INSTALL_MAN)/gsm.3: $(MAN)/gsm.3
  112. - -rm $@
  113. - cp $? $@
  114. - chmod 444 $@
  115. + ${BSD_INSTALL_MAN} $? $@
  116. $(GSM_INSTALL_MAN)/gsm_option.3: $(MAN)/gsm_option.3
  117. - -rm $@
  118. - cp $? $@
  119. - chmod 444 $@
  120. + ${BSD_INSTALL_MAN} $? $@
  121. $(GSM_INSTALL_MAN)/gsm_explode.3: $(MAN)/gsm_explode.3
  122. - -rm $@
  123. - cp $? $@
  124. - chmod 444 $@
  125. + ${BSD_INSTALL_MAN} $? $@
  126. $(GSM_INSTALL_MAN)/gsm_print.3: $(MAN)/gsm_print.3
  127. - -rm $@
  128. - cp $? $@
  129. - chmod 444 $@
  130. + ${BSD_INSTALL_MAN} $? $@
  131. $(GSM_INSTALL_INC)/gsm.h: $(INC)/gsm.h
  132. - -rm $@
  133. - cp $? $@
  134. - chmod 444 $@
  135. + ${BSD_INSTALL_DATA} $? $@
  136. $(GSM_INSTALL_LIB)/libgsm.a: $(LIBGSM)
  137. - -rm $@
  138. - cp $? $@
  139. - chmod 444 $@
  140. + ${BSD_INSTALL_DATA} $? $@
  141. + $(RANLIB) $@
  142. +$(INSTALLED_LIBGSMSO): $(LIBGSMSO)
  143. + ${BSD_INSTALL_MAN} $? $@
  144. +
  145. # Distribution
  146. dist: gsm-1.0.tar.Z
  147. @@ -416,16 +419,16 @@ uninstall: toastuninstall gsmuninstall
  148. @-echo uninstall: Done.
  149. semi-clean:
  150. - -rm $(RMFLAGS) */*.o \
  151. + $(RM) $(RMFLAGS) */*.o \
  152. $(TST)/lin2cod $(TST)/lin2txt \
  153. $(TST)/cod2lin $(TST)/cod2txt \
  154. $(TST)/gsm2cod \
  155. $(TST)/*.*.*
  156. -$(FIND) . \( -name core -o -name foo \) \
  157. - -print | xargs rm $(RMFLAGS)
  158. + -print | xargs $(RM) $(RMFLAGS)
  159. clean: semi-clean
  160. - -rm $(RMFLAGS) $(LIBGSM) $(ADDTST)/add \
  161. + $(RM) $(RMFLAGS) $(LIBGSM) $(ADDTST)/add \
  162. $(TOAST) $(TCAT) $(UNTOAST) \
  163. $(ROOT)/gsm-1.0.tar.Z
  164. @@ -434,29 +437,29 @@ clean: semi-clean
  165. # but aren't generally needed to port this.
  166. $(TLS)/sweet: $(TLS)/sweet.o $(TLS)/taste.o
  167. - $(LD) $(LFLAGS) -o $(TLS)/sweet \
  168. + $(CC) $(LFLAGS) -o $(TLS)/sweet \
  169. $(TLS)/sweet.o $(TLS)/taste.o $(LDLIB)
  170. $(TLS)/bitter: $(TLS)/bitter.o $(TLS)/taste.o
  171. - $(LD) $(LFLAGS) -o $(TLS)/bitter \
  172. + $(CC) $(LFLAGS) -o $(TLS)/bitter \
  173. $(TLS)/bitter.o $(TLS)/taste.o $(LDLIB)
  174. # A version of the same family that Jeff Chilton used to implement
  175. # the WAV #49 GSM format.
  176. $(TLS)/ginger: $(TLS)/ginger.o $(TLS)/taste.o
  177. - $(LD) $(LFLAGS) -o $(TLS)/ginger \
  178. + $(CC) $(LFLAGS) -o $(TLS)/ginger \
  179. $(TLS)/ginger.o $(TLS)/taste.o $(LDLIB)
  180. $(TLS)/sour: $(TLS)/sour.o $(TLS)/taste.o
  181. - $(LD) $(LFLAGS) -o $(TLS)/sour \
  182. + $(CC) $(LFLAGS) -o $(TLS)/sour \
  183. $(TLS)/sour.o $(TLS)/taste.o $(LDLIB)
  184. # Run $(ADDTST)/add < $(ADDTST)/add_test.dta to make sure the
  185. # basic arithmetic functions work as intended.
  186. $(ADDTST)/add: $(ADDTST)/add_test.o
  187. - $(LD) $(LFLAGS) -o $(ADDTST)/add $(ADDTST)/add_test.o $(LDLIB)
  188. + $(CC) $(LFLAGS) -o $(ADDTST)/add $(ADDTST)/add_test.o $(LDLIB)
  189. # Various conversion programs between linear, text, .gsm and the code
  190. @@ -474,21 +477,21 @@ $(TST)/test-result: $(TST)/lin2cod $(TST)/cod2lin $(TO
  191. ( cd $(TST); ./run )
  192. $(TST)/lin2txt: $(TST)/lin2txt.o $(LIBGSM)
  193. - $(LD) $(LFLAGS) -o $(TST)/lin2txt \
  194. + $(CC) $(LFLAGS) -o $(TST)/lin2txt \
  195. $(TST)/lin2txt.o $(LIBGSM) $(LDLIB)
  196. $(TST)/lin2cod: $(TST)/lin2cod.o $(LIBGSM)
  197. - $(LD) $(LFLAGS) -o $(TST)/lin2cod \
  198. + $(CC) $(LFLAGS) -o $(TST)/lin2cod \
  199. $(TST)/lin2cod.o $(LIBGSM) $(LDLIB)
  200. $(TST)/gsm2cod: $(TST)/gsm2cod.o $(LIBGSM)
  201. - $(LD) $(LFLAGS) -o $(TST)/gsm2cod \
  202. + $(CC) $(LFLAGS) -o $(TST)/gsm2cod \
  203. $(TST)/gsm2cod.o $(LIBGSM) $(LDLIB)
  204. $(TST)/cod2txt: $(TST)/cod2txt.o $(LIBGSM)
  205. - $(LD) $(LFLAGS) -o $(TST)/cod2txt \
  206. + $(CC) $(LFLAGS) -o $(TST)/cod2txt \
  207. $(TST)/cod2txt.o $(LIBGSM) $(LDLIB)
  208. $(TST)/cod2lin: $(TST)/cod2lin.o $(LIBGSM)
  209. - $(LD) $(LFLAGS) -o $(TST)/cod2lin \
  210. + $(CC) $(LFLAGS) -o $(TST)/cod2lin \
  211. $(TST)/cod2lin.o $(LIBGSM) $(LDLIB)