# Makefile for "cyrix.exe" -- a program to set/view the configuration
# registers for the DLC line of Cyrix processors.  (GNU version)
#
# Copyright 1994, by Paul Gortmaker.
#

# You need D.J. Delorie's djgpp (GNU c/c++ compiler for DOS) to build this.
# You can get djgpp for free. It is available on most FSF ftp sites.
# You can also order it from the FSF, or even DJ Delorie.
# With it you will also get GNU make, GNU as, and a bunch of other stuff.
# This makefile expects to be processed by GNU make. Other makes will choke.

# Note that the assembly is AT&T syntax, which is quite different
# than intel syntax (like that used by MASM, TASM, debug, etc.)
# There is a section in the "gas" (GNU assembler) manual that describes
# the different syntax if you are used to intel syntax.
# Or, you can just compare the assembly code here to the corresponding
# MASM code in the source tree for the MASM / MSC build.

# The main source "cyrix.c" is the same for both Microsoft and the GNU
# stuff. There are some #ifdef's to handle the differences.

# The default target is to prepend "stub.exe" to the coff output of gcc.
# (This is what coff2exe does.) However, you then need go32.exe to run
# the program. To make a standalone executable, you have to prepend
# go32.exe to the coff output of gcc. This can be done by the following:
#
#	copy /b go32.exe+cyrix cyrix.exe
#
# go32.exe is the 32 bit DOS extender that comes with djgpp, and in this
# case, cyrix is the coff output from gcc.

# If you don't have a floating point unit (387 chip) you will have to
# use "emu387" -- see the readme.

# Also watch out that DOS doesn't truncate the "ld" command line to its
# stupid 128 char limit when the env. variables get expanded. You will
# have to use response files if this bites you.

# These would be the default definitions for CC, LD and AS if you were
# using GNU/FSF make anyway, but we define them anyways.

CC = gcc
LD = ld
AS = as

# If you didn't set these in your autoexec.bat file when you installed
# djgpp, you better uncomment these lines. Make sure the path is set
# right for your system. Note the direction of the slashes!!!

# LIBRARY_PATH = c:/djgpp/lib
# COMPILER_PATH = c:/djgpp/lib
# C_INCLUDE_PATH = c:/djgpp/include
# GO32TMP = c:/tmp

CFLAGS = -Wall -Wstrict-prototypes -m486 -s -c
LDFLAGS = -s -L$(LIBRARY_PATH)
ASFLAGS =

OBJS = cyrix.o probe.o enable.o disable.o state.o
LIBS = -lpc -lc

# Uncomment the following lines for debugging, and remove the "-s" from
# the CFLAGS and LDFLAGS above

# DCFLAGS = -g -v
# DLDFLAGS = -g -v
# ASDFLAGS = -g -v

# Useless DOS. Should have a "rm".... grumble.
RM = del

# Implicit assembly rule (DOS can't support "*.S" vs. "*.s" - oh well.)

%.o : %.S
	$(AS) $(ASFLAGS) $(ASDFLAGS) $< -o $@

%.o : %.c
	$(CC) $(CFLAGS) $(DCFLAGS) $< -o $@

all: cyrix.exe

cyrix: $(OBJS)
	$(LD) -o cyrix $(LDFLAGS) $(DLDFLAGS) $(LIBRARY_PATH)/crt0.o $(OBJS) $(LIBS)

cyrix.exe : cyrix
	coff2exe cyrix

clean:
	$(RM) *.o
	$(RM) cyrix

spotless: clean
	$(RM) cyrix.exe
