libwinmain.a

ANOQ of the Sun anoq@hardcoreprocessing.com
Sun, 04 Jun 2000 17:52:06 +0200


This is a multi-part message in MIME format.
--------------9F02C5FFB93E65B483A67AA0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hello again!


I have attached the source code and Makefiles
for building libwinmain.a. Just put all the
files in the same directory, set the path
to the cross-compiler and execute

make target=win32

And you should have a libwinmain.a
I've got a precompiled one if you
would like to have it :)

This library would generally be useful
when crosscompiling to Windows I think.
So when I get a little time, I'll make
a small page about it on my homepage.


Cheers
-- 
http://www.HardcoreProcessing.com


--------------9F02C5FFB93E65B483A67AA0
Content-Type: text/plain; charset=us-ascii;
 name="Makefile"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="Makefile"

# Written by ANOQ of the Sun <anoq@HardcoreProcessing.com>

# There is no warranty of any kind and I will not be
# held responsible for any problems it may cause.

# Use at your own risk!

# Makefile for libwinmain.a
# type make target=win32 for crosscompiling Linux->Win32

# The library to be built
LIB = libwinmain.a
HCPGOBJS = winmain.o
LIBOBJS = $(HCPGOBJS)
USEMATH = true

include PortableGNUmake

ifeq ($(target), linux)
CC = $(CXX)
endif

# Dependencies
$(LIB): $(HCPGOBJS)

--------------9F02C5FFB93E65B483A67AA0
Content-Type: application/x-unknown-content-type-ProjectBuilder.c;
 name="winmain.c"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
 filename="winmain.c"

I2luY2x1ZGUgPHN0ZGxpYi5oPgojaW5jbHVkZSA8d2luZG93cy5oPgojaW5jbHVkZSAid2lubWFp
bi5oIgoKLyogVGhlIG9yaWdpbmFsIG1haW4gc2hvdWxkIGJlIHJlZGVmaW5lZCAoaW4geW91ciBh
cHBsaWNhdGlvbikKICAgc28gdGhhdCBpdCBpcyBjYWxsZWQgUnVuTWFpbi4gVGhpcyBpcyB3aGF0
IHdpbm1haW4uaAogICBkb2VzIHdoZW4geW91IGluY2x1ZGUgaXQgaW50byB5b3VyIGFwcGxpY2F0
aW9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AgICBPaCEgVGhhdCdzIHRoZSByZWFzb24gd2h5IHdl
J3JlIHdyaXRpbmcgTUwgY29tcGlsZXJzLi4uIDopICovCiAgd2hpbGUoKmxwQ21kTGluZSkKICB7
CiAgICBpZihpc1doaXRlU3BhY2UoKmxwQ21kTGluZSkpCiAgICB7CiAgICAgIGlmKGlzV29yZCkK
ICAgICAgewogICAgICAgIGlzV29yZCA9IDA7CiAgICAgICAgY250MisrOwogICAgICB9CiAgICB9
CiAgICBlbHNlCiAgICB7CiAgICAgIGlmKCFpc1dvcmQpCiAgICAgIHsKICAgICAgICBpc1dvcmQg
PSAxOwogICAgICAgIHJlc3VsdFtjbnQyXSA9IGxwQ21kTGluZTsKICAgICAgfQogICAgfQogICAg
bHBDbWRMaW5lKys7CiAgfQogIHJldHVybiByZXN1bHQ7Cn0KCmludCBXSU5BUEkgV2luTWFpbihI
SU5TVEFOQ0UgaEluc3RhbmNlLCBISU5TVEFOQ0UgaFByZXZJbnN0YW5jZSwgTFBTVFIgbHBDbWRM
aW5lLCBpbnQgblNob3dDbWQpCnsKICByZXR1cm4gUnVuTWFpbihXaW5Db3VudEFyZ3MobHBDbWRM
aW5lKSwgV2luQXJndihscENtZExpbmUpKTsKfQo=

--------------9F02C5FFB93E65B483A67AA0
Content-Type: application/x-unknown-content-type-ProjectBuilder.h;
 name="winmain.h"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
 filename="winmain.h"

I2lmbmRlZiBfX1dJTk1BSU5fSF9fCiNkZWZpbmUgX19XSU5NQUlOX0hfXwoKI2lmZGVmIF9fY3Bs
dXNwbHVzCiNkZWZpbmUgQ19MSU5LQUdFICAgICAgICJDIgojZWxzZQojZGVmaW5lIENfTElOS0FH
RQojZW5kaWYgLyogX19jcGx1c3BsdXMgKi8KCi8qIFRoZSBwcm90b3R5cGUgZm9yIHRoZSBhcHBs
aWNhdGlvbidzIG1haW4oKSBmdW5jdGlvbiAqLwpleHRlcm4gQ19MSU5LQUdFIGludCBSdW5NYWlu
KGludCBhcmdjLCBjaGFyICphcmd2W10pOwoKI2VuZGlmIC8qIF9fV0lOTUFJTl9IX18gKi8=

--------------9F02C5FFB93E65B483A67AA0
Content-Type: text/plain; charset=us-ascii;
 name="PortableGNUmake"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="PortableGNUmake"


# GNU Makefile -- autodetects host type and sets appropriate variables

# Modified by ANOQ of the Sun <anoq@HardcoreProcessing.com>

# There is no warranty of any kind and I will not be
# held responsible for any problems it may cause.

# Use at your own risk!

# These variables will be honored if defined:
#  TARGET -- the make target
#  DEFS   -- special CFLAGS definitions
#  HDRS   -- special include directories
#  LIBS   -- special libraries to link with

# Set this next variable to the SDL directory path
ifeq ($(SDL), )
SDL_DIR += ../SDL ../SDL-[0-9].[0-9] ../SDL-[0-9].[0-9].[0-9]
SDL_DIR += ../../SDL ../../SDL-[0-9].[0-9] ../../SDL-[0-9].[0-9].[0-9]
SDL_DIR += /usr/
ifeq ($(target), win32)
SDL := /usr/local/cross-tools/i386-mingw32
else
SDL := $(firstword $(wildcard $(SDL_DIR)))
endif
endif

# Figure out what system we are compiling for
ifeq ($(target), )
target := $(shell uname | tr '[A-Z]' '[a-z]')
endif

# Set some default initial values
SDLINC := 
SDLLIB := 

# Linux, the choice of a GNU generation. :-)
ifeq ($(target), linux)
glibc := $(shell ./GNUC.sh 2>/dev/null || ../GNUC.sh 2>/dev/null || echo true)
ifeq ($(debug), true)
 OPTIMIZE = -g
else
 OPTIMIZE = -O2 -funroll-loops -fomit-frame-pointer -ffast-math
endif
ifeq ($(static), true)
 SDLLIB := $(SDLLIB) -L/usr/X11R6/lib -lX11 -lXext -lXxf86dga -lXxf86vm
else
 SDLLIB := $(SDLLIB) -Wl,-rpath,$(shell cd $(SDL) && pwd)/lib -ldl
endif
 MATHLIB = -lm
ifeq ($(glibc), true)
 DEFS += -D_REENTRANT
 LIBS += -lpthread
endif
endif

# Solaris 2.x (using gcc)
ifeq ($(target), sunos)
ifeq ($(debug), true)
 OPTIMIZE = -g
else
 OPTIMIZE = -O2 -funroll-loops -fomit-frame-pointer -ffast-math
endif
ifeq ($(static), true)
 SDLLIB := $(SDLLIB) -lSDL -L/usr/openwin/lib -lX11 -lXext
else
 SDLLIB := $(SDLLIB) -Wl,-R,$(shell cd $(SDL) && pwd)/lib -lSDL -ldl
endif
 MATHLIB = -lm
 INETLIB = -lsocket -lnsl
 DEFS += -D_REENTRANT
 LIBS += -lpthread
 RANLIB = :
endif

# IRIX 6.x (using gcc)
ifeq ($(target), irix)
# dynamic linking doesn't work with gcc on IRIX
static = true
 CC = gcc
ifeq ($(debug), true)
 OPTIMIZE = -g
else
 OPTIMIZE = -O2 -funroll-loops -fomit-frame-pointer -ffast-math
endif
ifeq ($(static), true)
 SDLLIB := $(SDLLIB) -lSDL
else
 SDLLIB := $(SDLLIB) -lSDL -lX11 -lXext -lpthread -laudio
endif
 MATHLIB = -lm
 INETLIB = 
 RANLIB = :
endif

# OSF/1 3.2
ifeq ($(target), osf1)
ifeq ($(debug), true)
 OPTIMIZE = -g
else
 OPTIMIZE = -O2
endif
ifeq ($(static), true)
 SDLLIB := $(SDLLIB) -lSDL
else
 SDLLIB := $(SDLLIB) -lSDL
endif
 MATHLIB = -lm
 INETLIB = 
 RANLIB = ranlib
endif

# Win32 cross-compilation
ifeq ($(target), cygwin32_95)
target := win32
endif
ifeq ($(target), cygwin32_nt)
target := win32
endif
ifeq ($(target), win32)
 TARGET := $(TARGET:=.exe)
ifeq ($(debug), true)
 OPTIMIZE = -g
else
 OPTIMIZE = -O2 -funroll-loops -fomit-frame-pointer -ffast-math
endif
 SDLLIB := $(SDLLIB) -lmingw32 -luser32 -lgdi32 -lwinmm -ldxguid
# Set this flag for console applications -mwindows
 INETLIB = -lwsock32
endif

# BeOS Metrowerks
ifeq ($(target), beos)
 CXX = mwcc
ifeq ($(debug), true)
 OPTIMIZE = -g
else
 OPTIMIZE = -O7
endif
 SDLLIB := $(SDLLIB) -lSDL
endif

# Finish setting the various compilation flags
ifeq ($(SDLIMAGE), true)
 LIBS += -lSDL_image
endif

ifeq ($(SDLIMAGEPNG), true)
 LIBS += -lz -lpng
endif

ifeq ($(static), true)
DEFS += -D_SDL_STATIC_LIB
endif
CPPFLAGS = $(SDLINC) $(INCLUDE) $(HDRS) $(OPTIMIZE) $(DEFS)
LDFLAGS = $(LIBS) $(SDLLIB)
ifneq ($(USEMATH), )
LDFLAGS += $(MATHLIB)
endif
ifneq ($(USEINET), )
LDFLAGS += $(INETLIB)
endif
ifeq ($(RANLIB), )
RANLIB = ranlib
endif

# If there is a library, build it first
ifneq ($(LIB), )
$(LIB): $(LIBOBJS)
	$(AR) crv $@ $(LIBOBJS)
	$(RANLIB) $@
endif

# The demos are the targets
all: $(TARGET)

# Make the targets
$(TARGET): SDL_path_OK $(SDL)/lib/libSDL.a
	$(CC) -o $@ $(filter %.o, $^) $(LDFLAGS)
	@if [ "$(target)" = "win32" ]; then \
		for lib in $(SDL)/lib/*.dll; \
		do if [ -f $$lib ]; then \
			echo "$$lib -> ."; \
			cp $$lib .; \
		   fi; \
		done; \
	 fi
	@if [ ! -h "add-ons" ]; then \
		ln -s $(SDL)/lib add-ons; \
	 fi


# Clean up object files
clean:
ifneq ($(SUBDIRS), )
	for subdir in $(SUBDIRS); do \
		$(MAKE) -C $$subdir $@; \
	done
endif
	rm -f *.o *~ std???.txt DEADJOE core SDL_path_OK $(EXTRACLEAN)


# Remove everything recoverable
distclean: clean
ifneq ($(SUBDIRS), )
	for subdir in $(SUBDIRS); do \
		$(MAKE) -C $$subdir $@; \
	done
endif
	rm -f $(LIB) $(TARGET) $(TARGET:=.exe) *.LIB SDL-???.dll add-ons

spotless: distclean


# Force the SDL variable to be defined and valid
ifeq ($(SDL), )
SDL_path_OK:
	@echo
	@echo "-> You must set the SDL variable in the Makefile"
	@echo
	@exit 1
else
SDL_path_OK:
	@if [ ! -d $(SDL)/include -o ! -d $(SDL)/lib ]; then \
		echo "Couldn't find SDL in $(SDL)"; \
		exit 1; \
	 fi
	@touch SDL_path_OK
endif


--------------9F02C5FFB93E65B483A67AA0--