Skip to content

Commit

Permalink
Makefile.mk: portable Makefile.m32
Browse files Browse the repository at this point in the history
Update bare GNU Make `Makefile.m32` to:

- Move objects into a subdirectory.
- Add support for MS-DOS. Tested with DJGPP.
- Add support for Watt-32 (on MS-DOS).
- Add support for AmigaOS.
- Rename `Makefile.m32` to `Makefile.mk`
- Replace `ARCH` with `TRIPLET`.
- Build `tool_hugehelp.c` proper (when tools are available).
- Drop MS-DOS compatibility macro `USE_ZLIB` (replaced by `HAVE_LIBZ`)
- Add support for `ZLIB_LIBS` to override `-lz`.
- Omit object files when building examples.
- Default `CC` to `gcc` once again, for convenience. (Caveat: compiler
  name `cc` cannot be set now.)
- Set `-DCURL_NO_OLDIES` for examples, like autotools does.
- Delete `makefile.dj` files. Notice the configuration details and
  defaults are not retained with the new method.
- Delete `makefile.amiga` files. A successful build needs a few custom
  options. We're also not retaining all build details from the existing
  Amiga make files.
- Rename `Makefile.m32` to `Makefile.mk` to reflect that they are not
  Windows/MinGW32-specific anymore.
- Add support for new `CFG` options: `-map`, `-debug`, `-trackmem`
- Set `-DNDEBUG` by default.
- Allow using `-DOS=...` in all `lib/config-*.h` headers, syncing this
  with `config-win32.h`.
- Look for zlib parts in `ZLIB_PATH/include` and `ZLIB_PATH/lib`
  instead of bare `ZLIB_PATH`.

Note that existing build configurations for MS-DOS and AmigaOS likely
become incompatible with this change.

Example AmigaOS configuration:
```
export CROSSPREFIX=/opt/amiga/bin/m68k-amigaos-
export CC=gcc
export CPPFLAGS='-DHAVE_PROTO_BSDSOCKET_H'
export CFLAGS='-mcrt=clib2'
export LDFLAGS="${CFLAGS}"
export LIBS='-lnet -lm'
make -C lib -f Makefile.mk
make -C src -f Makefile.mk
```

Example MS-DOS configuration:
```
export CROSSPREFIX=/opt/djgpp/bin/i586-pc-msdosdjgpp-
export WATT_PATH=/opt/djgpp/net/watt
export ZLIB_PATH=/opt/djgpp
export OPENSSL_PATH=/opt/djgpp
export OPENSSL_LIBS='-lssl -lcrypt'
export CFG=-zlib-ssl
make -C lib -f Makefile.mk
make -C src -f Makefile.mk
```

Closes curl#9764
  • Loading branch information
vszakats committed Nov 22, 2022
1 parent 4a8b4a1 commit a8861b6
Show file tree
Hide file tree
Showing 25 changed files with 318 additions and 707 deletions.
2 changes: 2 additions & 0 deletions .github/scripts/spellcheck.words
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ dir
distro
distro's
distros
DJGPP
dlist
DLL
dll
Expand Down Expand Up @@ -226,6 +227,7 @@ FreeDOS
FreeRTOS
freshmeat
Frexx
FS
fseek
FTPing
fuzzer
Expand Down
34 changes: 17 additions & 17 deletions Makefile.dist
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,25 @@ ssl:
make

mingw32:
$(MAKE) -C lib -f Makefile.m32
$(MAKE) -C src -f Makefile.m32
$(MAKE) -C lib -f Makefile.mk
$(MAKE) -C src -f Makefile.mk

mingw32-clean:
$(MAKE) -C lib -f Makefile.m32 clean
$(MAKE) -C src -f Makefile.m32 clean
$(MAKE) -C docs/examples -f Makefile.m32 clean
$(MAKE) -C lib -f Makefile.mk clean
$(MAKE) -C src -f Makefile.mk clean
$(MAKE) -C docs/examples -f Makefile.mk clean

mingw32-vclean mingw32-distclean:
$(MAKE) -C lib -f Makefile.m32 vclean
$(MAKE) -C src -f Makefile.m32 vclean
$(MAKE) -C docs/examples -f Makefile.m32 vclean
$(MAKE) -C lib -f Makefile.mk vclean
$(MAKE) -C src -f Makefile.mk vclean
$(MAKE) -C docs/examples -f Makefile.mk vclean

mingw32-examples%:
$(MAKE) -C docs/examples -f Makefile.m32 CFG=$@
$(MAKE) -C docs/examples -f Makefile.mk CFG=$@

mingw32%:
$(MAKE) -C lib -f Makefile.m32 CFG=$@
$(MAKE) -C src -f Makefile.m32 CFG=$@
$(MAKE) -C lib -f Makefile.mk CFG=$@
$(MAKE) -C src -f Makefile.mk CFG=$@

vc:
cd winbuild
Expand All @@ -59,9 +59,9 @@ vc-x64:
cd winbuild
nmake /f Makefile.vc MACHINE=x64

djgpp:
$(MAKE) -C lib -f Makefile.dj
$(MAKE) -C src -f Makefile.dj
djgpp%:
$(MAKE) -C lib -f Makefile.mk CFG=$@ CROSSPREFIX=i586-pc-msdosdjgpp-
$(MAKE) -C src -f Makefile.mk CFG=$@ CROSSPREFIX=i586-pc-msdosdjgpp-

cygwin:
./configure
Expand All @@ -71,9 +71,9 @@ cygwin-ssl:
./configure --with-openssl
make

amiga:
cd ./lib && make -f makefile.amiga
cd ./src && make -f makefile.amiga
amiga%:
$(MAKE) -C lib -f Makefile.mk CFG=$@ CROSSPREFIX=m68k-amigaos-
$(MAKE) -C src -f Makefile.mk CFG=$@ CROSSPREFIX=m68k-amigaos-

unix: all

Expand Down
28 changes: 26 additions & 2 deletions docs/INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ make targets available to build libcurl with more features, use:
and SSPI support.

If you have any problems linking libraries or finding header files, be sure
to verify that the provided `Makefile.m32` files use the proper paths, and
to verify that the provided `Makefile.mk` files use the proper paths, and
adjust as necessary. It is also possible to override these paths with
environment variables, for example:

Expand Down Expand Up @@ -210,7 +210,7 @@ set LDFLAGS=-Lc:/openldapsdk/lib/mscvc
set LIBS=-lldapsdk -lldapssl -lldapx
```

If you want to enable LDAPS support then set LDAPS=1.
If you want to enable LDAPS support then append `-ldaps` to the make target.

## Cygwin

Expand All @@ -220,6 +220,30 @@ executable in `/bin/` or you will see the configure fail toward the end.

Run `make`

## MS-DOS

Requires DJGPP in the search path and pointing to the Watt-32 stack via
`WATT_PATH=c:/djgpp/net/watt`.

Run `make -f Makefile.dist djgpp` in the root curl dir.

For build configuration options, please see the MinGW32 section.

Notes:

- DJGPP 2.04 beta has a `sscanf()` bug so the URL parsing is not done
properly. Use DJGPP 2.03 until they fix it.

- Compile Watt-32 (and OpenSSL) with the same version of DJGPP. Otherwise
things go wrong because things like FS-extensions and `errno` values have
been changed between releases.

## AmigaOS

Run `make -f Makefile.dist amiga` in the root curl dir.

For build configuration options, please see the MinGW32 section.

## Disabling Specific Protocols in Windows builds

The configure utility, unfortunately, is not available for the Windows
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

AUTOMAKE_OPTIONS = foreign nostdinc

EXTRA_DIST = README.md Makefile.example Makefile.inc Makefile.m32 \
makefile.dj $(COMPLICATED_EXAMPLES) .checksrc
EXTRA_DIST = README.md Makefile.example Makefile.inc Makefile.mk \
$(COMPLICATED_EXAMPLES) .checksrc

# Specify our include paths here, and do it relative to $(top_srcdir) and
# $(top_builddir), to ensure that these paths which belong to the library
Expand Down
44 changes: 30 additions & 14 deletions docs/examples/Makefile.m32 → docs/examples/Makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -22,37 +22,53 @@
#
#***************************************************************************

# Build libcurl via lib/Makefile.m32 first.
# Build libcurl via lib/Makefile.mk first.

PROOT := ../..

ifeq ($(findstring -static,$(CFG)),)
DYN := 1
endif

### Common

include $(PROOT)/lib/Makefile.mk

### Local

CPPFLAGS += -DCURL_NO_OLDIES
LDFLAGS += -L$(PROOT)/lib
LIBS += -lcurl
LIBS := -lcurl $(LIBS)

ifeq ($(findstring -static,$(CFG)),)
ifdef DYN
curl_DEPENDENCIES += $(PROOT)/lib/libcurl.dll.a
DYN := 1
else
curl_DEPENDENCIES := $(PROOT)/lib/libcurl.a
CPPFLAGS += -DCURL_STATICLIB
LDFLAGS += -static
ifdef WIN32
CPPFLAGS += -DCURL_STATICLIB
LDFLAGS += -static
endif
endif

LIBS += -lws2_32
ifdef WIN32
LIBS += -lws2_32
endif

### Sources and targets

# Provides check_PROGRAMS
include Makefile.inc

TARGETS := $(patsubst %,%.exe,$(strip $(check_PROGRAMS) synctime))
TOCLEAN := $(TARGETS:.exe=.o)
ifdef WIN32
check_PROGRAMS += synctime
endif

### Local rules
TARGETS := $(patsubst %,%$(BIN_EXT),$(strip $(check_PROGRAMS)))
TOCLEAN := $(TARGETS)

%.exe: %.o $(curl_DEPENDENCIES)
$(CC) $(LDFLAGS) $(CURL_LDFLAGS_BIN) -o $@ $< $(LIBS)
### Rules

### Global script
%$(BIN_EXT): %.c $(curl_DEPENDENCIES)
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(CURL_LDFLAGS_BIN) $< -o $@ $(LIBS)

include $(PROOT)/lib/Makefile.m32
all: $(TARGETS)
57 changes: 0 additions & 57 deletions docs/examples/makefile.dj

This file was deleted.

6 changes: 3 additions & 3 deletions lib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ AUTOMAKE_OPTIONS = foreign nostdinc

CMAKE_DIST = CMakeLists.txt curl_config.h.cmake

EXTRA_DIST = Makefile.m32 config-win32.h config-win32ce.h config-plan9.h \
config-riscos.h config-mac.h curl_config.h.in makefile.dj config-dos.h \
libcurl.plist libcurl.rc config-amigaos.h makefile.amiga config-win32ce.h \
EXTRA_DIST = Makefile.mk config-win32.h config-win32ce.h config-plan9.h \
config-riscos.h config-mac.h curl_config.h.in config-dos.h \
libcurl.plist libcurl.rc config-amigaos.h config-win32ce.h \
config-os400.h setup-os400.h $(CMAKE_DIST) setup-win32.h .checksrc

lib_LTLIBRARIES = libcurl.la
Expand Down
Loading

0 comments on commit a8861b6

Please sign in to comment.